package com.yzzrjy.old;

import com.yzzrjy.Service.UserService;
import com.yzzrjy.bean.UserBaseBean;
import com.yzzrjy.util.DruidUtils;
import com.yzzrjy.util.ResponseUtils;
import org.apache.commons.dbutils.QueryRunner;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(name = "SendGiftServlet", value = "/sendGift")
public class SendGiftServlet extends HttpServlet {
    private UserService userService = new UserService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        response.setCharacterEncoding("utf-8");
        String uid = request.getParameter("uid");
        String token = request.getParameter("token");
        String liveUid = request.getParameter("liveUid");
        String sessionId = request.getParameter("sessionId");
        String gid = request.getParameter("gid");
        String num = request.getParameter("num");
        if(uid == null || token == null || uid.length() == 0 || token.length() == 0 ||
            liveUid == null || sessionId == null || gid == null || num == null){
            ResponseUtils.parameterError(response);
            return;
        }
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());
        try {
            UserBaseBean userBaseBean = userService.getUserBase(uid);
            if(userBaseBean == null){
                ResponseUtils.userNotExist(response);
                return;
            }


        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
